Auto merge of #1804 - alexcrichton:aggressively-backtrack, r=brson
authorbors <bors@rust-lang.org>
Fri, 17 Jul 2015 20:26:42 +0000 (20:26 +0000)
committerbors <bors@rust-lang.org>
Fri, 17 Jul 2015 20:26:42 +0000 (20:26 +0000)
Resolving a dependency graph may involve quite a bit of backtracking to select
different versions of crates, but the previous implementation of resolution
would not backtrack enough.

Once a dependency is completely resolved it's possible that any number of
candidates for its transitive dependencies were left out of the resolution
process (e.g. we didn't hit them yet). These candidates were not previously used
for backtracking (because resolution overall of the dependency finished), but
this commit alters the implementation to instead consider these as candidates
for backtracking.

Architecturally this changes the code to CPS to pass around a `finished`
continuation to allow tweaking the behavior whenever a dependency successfully
resolves. The key change is then that whenever a candidate for a dependency is
activated, we ensure the recursive step for the rest of the graph happens as a
sub-call. This means that if *anything* in the recursive call fails (including
some previous up-the-stack resolution) we'll retry the next candidate.

Closes #1800


Trivial merge